<!-- StudyTeamList_Frame.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>小组列表</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css"/>
		<link rel="stylesheet" href="../../css/base.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css">
			.base_right_item{
				text-align: center;
				font-size: 14px;
			}
			.plan-table-view{
				background-color: #f3f5f7;
			}
			.plan-cell{
				background-color: white;
				margin-bottom: 8px;
			}
			.plan-cell .cell-p{
				margin: 0;
				font-size: 14px;
				line-height: 30px;
				color: #333;
			}
			.plan-cell .cell-left-div{
				width: 100px;
				height: 30px;
				float: left;
			}
			.plan-cell .cell-right-div{
				margin-left: 100px;
				height: 30px;
			}
			input[type=text]{
				border: none;
				margin: 0;
				padding: 0;
				height: 30px;
				font-size: 14px;
				color: #333;
			}
			.time-input{
				font-size: 14px;
				line-height: 30px;
				height: 30px;
				color: #333;
			}
		</style>
	</head>
	<body>
		<ul id="team_list_view" class="mui-table-view plan-table-view">
			<!-- <li class="mui-table-view-cell plan-cell">
				<a class="mui-navigate-right">
					<p class="cell-p">
						小组名称A
					</p>
				</a>
			</li>
			<li class="mui-table-view-cell plan-cell">
				<a class="mui-navigate-right">
					<p class="cell-p">
						小组名称B
					</p>
				</a>
			</li>
			<li class="mui-table-view-cell plan-cell">
				<a class="mui-navigate-right">
					<p class="cell-p">
						小组名称C
					</p>
				</a>
			</li> -->
		</ul>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="loadData()">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var teamArr = new Array();
		apiready = function() {
			setRefreshHeader();
			loadData();
			setupNotifi();
		}
		function setupNotifi(){
			api.addEventListener({
			    name: 'creatTeamSucceedNotifi'
			}, function(ret, err) {
			    loadData();
			});
			api.addEventListener({
			    name: 'planTeamListRefreshNotifi'
			}, function(ret, err) {
			    loadData();
			});
			api.addEventListener({
			    name: 'delUserSuccessNotifi'
			}, function(ret, err) {
			    loadData();
			});
			api.addEventListener({
			    name: 'addPlanTeamStuNotifi'
			}, function(ret, err) {
			    loadData();
			});
		}
		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				loadData();
			});
		}
		function loadData(){
			var params = {
				pid : api.pageParam.pid,
				jid : $api.getStorage('cfnetppjxid')
			};
			cfnetppPOST(url_planTeamList, params, true, function(data, status){
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.code == 200) {
						var teamList = data.data;
						if (teamList != null && teamList.constructor == Array && teamList.length > 0) {
							teamArr = teamList;
							var teamListHtmlString = new String();
							for (var i = 0; i < teamList.length; i++) {
								var teamData = teamList[i];
								teamListHtmlString += htmlStringWithData(i, teamData);
							}
							$('#team_list_view').html(teamListHtmlString);
							addCellClick();
							$('#noData').hide();
							$('#noNet').hide();
						}else{
							$('#team_list_view').html('');
							$('#noData').show();
							$('#noNet').hide();
						}
					}else{
						$('#team_list_view').html('');
						$('#noData').show();
						$('#noNet').hide();
					}
				}else{
					$('#team_list_view').html('');
					$('#noData').hide();
					$('#noNet').show();
				}
			});
		}
		function htmlStringWithData(index, data){
			return '<li index="'+index+'" id="'+data.id+'" class="mui-table-view-cell plan-cell">'+
				'<a class="mui-navigate-right">'+
					'<p class="cell-p">'+
						data.names+
					'</p>'+
				'</a>'+
			'</li>';
		}
		function addCellClick(){
			$('.plan-cell').unbind('click');
			$('.plan-cell').click(function(){
				var index = $(this).attr('index');
				var teamData = teamArr[parseInt(index)];
				teamData["currenttype"] = "edit";
				teamData["pid"] = api.pageParam.pid;
				api.openWin({useWKWebView:true,
				    name: 'StudyCreatTeam',
				    url: 'StudyCreatTeam.html',
				    pageParam: teamData
				});
			});
		}
	</script>
</html>